<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>申请加入</title>
<link href="/res/css/respective/company/aztCom.css" rel="stylesheet">
	<style type="text/css">
        .roleItem span {
            margin-right: 0;
            color: #f6a422;
        }
	</style>
</head>
<body> 
	<div class="warp">
		[#include "/front/common/front_headAzt.html"]
		<div class="backcontent">
			[#include "/front/common/front_leftAzt.html"]
			<div class="back-main">
				<div class="mainContent">
					<div class="mainContentWhite comAply">
                        <form id="applyForm" data-validator-option="{theme:'yellow_right',timely:3, focusCleanup:true,stopOnError:true,focusInvalid:true}">
                            <input type="hidden" id="companyId" name="companyId" value="${company.id!}">
							<h1><big>您正在申请加入</big><b style="color: #00b1db;">${company.companyName!}</b></h1>
							<h2 class="thirdTitle">请输入您的身份</h2>
							<div class="lableIterm">
								 <label><span>*</span>真实姓名：</label>
								 <input type="text" placeholder="请填写真实姓名" id="realName" name="realName" value="${Session.currentUser.realName!}" data-rule="真实姓名:required;"/>
							</div>
							<div class="lableIterm">
								 <label><span>*</span>联系方式：</label>
								 <input type="text" placeholder="请填写联系方式" id="mobile" name="mobile" value="${Session.currentUser.mobile!}" data-rule="联系方式:required;"/>
							</div>
							[#if roleList?? && roleList?size > 0]
							<h2 class="thirdTitle">请输入您的身份</h2>
							<div class="lableIterm roleItem">
								 <label><span>*</span>所属角色：</label>
								 <div class="ppSelect">
									<select id="roleId" name="roleId">
										 <option value="">请选择所属角色</option>
										 [#list roleList as role]
											<option value="${role.id!}">${role.name!}[#if role.roleType==1]（采购商）[/#if][#if role.roleType==2]（供应商）[/#if]</option>
										 [/#list]
									</select>
								 </div>
							</div>
							[/#if]
							<div class="lableIterm">
								 <label><span>*</span>请输入申请说明：</label>
								 <textarea rows="5" cols="95" name="applyReason" id="applyReason" placeholder="例：我是安装通的采购员，张三"
										   data-rule="申请说明:required; length(~50)" data-msg-length="申请说明最多为50个字"></textarea>
							</div>
							<div class="lableIterm">
								 <label></label>
								 <button type="button" class="blueButt" style="margin-right: 20px;" onclick="saveCompanyApply()">保存</button>
								 <button type="button" class="whiteButt" onclick="location.href='/user/companySearch'">取消</button>
							</div>
						</form>
					</div> 
				</div>
			</div> 
		</div>
		<!-- 底部菜单-->
		[#include "/front/common/front_footerAzt.html"]
	</div>
	<script src="/res/js/common/common.js" type="text/javascript"></script>
    <script src="/res/third/layer/layer.js" type="text/javascript"></script>
    <script src="/res/third/nice-validator/jquery.validator.min.js?local=zh-CN" type="text/javascript"></script>
	<script type="text/javascript">
        function saveCompanyApply() {
            if($('#applyForm').isValid()) {
                $.ajax({
                    url: '/user/saveApplyCompany',
                    data: $('#applyForm').serialize(),
                    type: 'post',
                    dataType: 'json',
                    beforeSend : function () {
                        layer.load(2, {shade: 0.1});
                    },
                    success: function (data) {
                        if (data && data.success) {
                            window.location.replace('/user/companySearch');
                        } else {
                            layer.alert(data.msg);
                        }
                    },
                    complete : function() {
                        layer.closeAll('loading');
                    }
                });
            }
        }
	</script>
</body>
</html>